<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>添加银行卡</title>
    <link rel="stylesheet" type="text/css" href="../../../../css/aui/aui.css" />
    <link rel="stylesheet" type="text/css" href="../../../../script/layui/layui.css" />
    <style>
        html,
        body {
            background: #fff;
        }

        #app {
            padding: 1.5rem 2.5rem;
        }

        .btn {
            background: #0689FB;
            width: 100%;
            height: 2rem;
            text-align: center;
            line-height: 2rem;
            color: #fff;
            margin: 2rem auto 0;
            border-radius: 0.2rem;
        }

        .inp_box {
            border: 1px solid #eee;
            padding: 0 0.5rem;
            margin-bottom: 0.5rem;
        }

        .note {
            font-size: 0.6rem;
            color: #999;
            margin-top: 2rem;
        }

        .layui-form-select dl dd.layui-this {
            background: #eee !important;
            color: #212121;
        }
    </style>
</head>

<body>
    <div id="app" class="layui-form">

        <div class='inp_box'>
            <select name="" id="back">
                <option value="">请选择银行卡名称</option>
                <option value="BOC">中国银行</option>
                <option value="ICBC">中国工商银行</option>
                <option value="ABC">中国农业银行</option>
                <option value="CBC">中国建设银行</option>
                <option value="CCB">交通银行</option>
                <option value="PSBC">中国邮政储蓄银行</option>
                <option value="CMB">招商银行</option>
                <option value="CIB">兴业银行</option>
                <option value="CMBC">中国民生银行</option>
                <option value="CITIC">中信银行</option>
                <option value="SPDB">上海浦东发展银行</option>
            </select>
        </div>
        <div class='inp_box'>
            <input type="number" id="bank_card" placeholder="请输入银行卡号" class="layui-input">
        </div>
        <div class='inp_box'>
            <input type="tel" id="user_tel" placeholder="请输入手机号" class="layui-input">
        </div>
        <div class='inp_box'>
            <input type="text" id="user_name" placeholder="请输入持卡人姓名" class="layui-input">
        </div>
        <div class="btn" onclick="submit()">添加</div>


        <div class="note">备注：手动提现将打款至您添加的银行账户内，请确保账号的准确，谢谢！</div>
    </div>
</body>
<script src="../../../../script/api.js" charset="utf-8"></script>
<script src="../../../../script/aui/aui-tab.js" charset="utf-8"></script>
<script src="../../../../script/common/jquery-3.3.1.min.js" charset="utf-8"></script>
<script src="../../../../script/common/check.js" charset="utf-8"></script>
<script src="../../../../script/common/common.js" charset="utf-8"></script>
<script src="../../../../script/common/config.js" charset="utf-8"></script>
<script src="../../../../script/layui/layui.all.js" charset="utf-8"></script>
<script>
    apiready = function() {
        api.parseTapmode();

    }

    function submit() {
        var userInfo = get_local("userInfo");
        var bank_code = $("#back").val();
        var data = {
            user_id: userInfo.user_id,
            bank_code: bank_code,
            bank_name: getBankName(bank_code),
            bank_card: $("#bank_card").val(),
            user_tel: $("#user_tel").val(),
            user_name: $("#user_name").val(),
        };

        if (!is_define(data.bank_name)) {
            $toast("请选择银行卡类型");
            return;
        } else if (!is_define(data.bank_card)) {
            $toast("请输入银行卡号");
            return;
        } else if (data.bank_card.length < 16) {
            $toast("请输入正确的银行卡号");
            return;
        } else if (!is_define(data.user_tel)) {
            $toast("请输入手机号");
            return;
        } else if (!checkMobile(data.user_tel)) {
            $toast("请输入正确的手机号");
            return;
        } else if (!is_define(data.user_name)) {
            $toast("请输入持卡人姓名");
            return;
        }
        _ajax(Config.api.UserBankCreate, data, function(ret) {
            if (ret.code === 200) {
                $toast("添加成功");
                api.execScript({
                    name: 'my_bank_card_win',
                    frameName: 'my_bank_card_frm',
                    script: 'vm.getList()'
                });
                setTimeout(function() {
                    close_w();
                }, 1000);
            }
        });
    }

    function getBankName(bank_code) {
        var bank = [{
            "bank_code": "BOC",
            "bank_name": "中国银行"
        }, {
            "bank_code": "ICBC",
            "bank_name": "中国工商银行"
        }, {
            "bank_code": "ABC",
            "bank_name": "中国农业银行"
        }, {
            "bank_code": "CBC",
            "bank_name": "中国建设银行"
        }, {
            "bank_code": "CCB",
            "bank_name": "交通银行"
        }, {
            "bank_code": "PSBC",
            "bank_name": "中国邮政储蓄银行"
        }, {
            "bank_code": "CMB",
            "bank_name": "招商银行"
        }, {
            "bank_code": "CIB",
            "bank_name": "兴业银行"
        }, {
            "bank_code": "CMBC",
            "bank_name": "中国民生银行"
        }, {
            "bank_code": "CITIC",
            "bank_name": "中信银行"
        }, {
            "bank_code": "SPDB",
            "bank_name": "上海浦东发展银行"
        }];

        for (var i = 0; i < bank.length; i++) {
            if (bank[i].bank_code === bank_code) {
                return bank[i].bank_name;
                break;
            }
        }
    }
</script>

</html>
